{% liquid
  assign viewAllLink = ""
  assign viewAllText = ""
  for sublink in submenu
    assign firstCharacter = sublink.title | slice: 0, 1
    assign lastCharacter = sublink.title | slice: -1, 1 
    if sublink.levels == 0 and firstCharacter == "#" and lastCharacter == "#"
        assign viewAllLink = sublink.url
        assign viewAllText = sublink.title | remove_first: '#' | remove_last: '#' 
      endif
  endfor
%}

{% if viewAllLink != '' %} 
  <div class="d-lg-flex d-none w-100 py-3 flex-center border-top">
    <a class="btn btn-outline-primary btn-sm" style="font-size:.875rem;" {% if viewAllLink contains 'https://' %} target="_blank" rel="nofollow" {% endif %} href="{{ viewAllLink }}">
      {% comment %} {{ 'sections.header.view_all' | t }} {% endcomment %}
      {{ viewAllText }}
    </a>
  </div>
  <div class="d-lg-none d-flex w-100 pb-3 flex-center">
    <a class="btn btn-outline-primary btn-sm w-100" style="font-size:.875rem;" {% if viewAllLink contains 'https://' %} target="_blank" rel="nofollow" {% endif %} href="{{ viewAllLink }}">
      {% comment %} {{ 'sections.header.view_all' | t }} {% endcomment %}
      {{ viewAllText }}
    </a>
  </div>
{% endif %}